//
//  CommentTableViewCell.m
//  ArtDog
//
//  Created by dllo on 16/9/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CommentTableViewCell.h"
#import "CommentList.h"
#import "UIImageView+WebCache.h"
#import "NSString+Common.h"
#import "HLMacro.h"

static CGFloat height;

@interface CommentTableViewCell ()



@property (weak, nonatomic) IBOutlet UILabel *usernameLabel;


@property (weak, nonatomic) IBOutlet UILabel *contentLabel;


@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UIImageView *headPicImage;

@property (weak, nonatomic) IBOutlet UIImageView *praiseImage;

@property (weak, nonatomic) IBOutlet UILabel *praiseNumLabel;

@property (weak, nonatomic) IBOutlet UIImageView *commentImage;

@property (weak, nonatomic) IBOutlet UILabel *commentNumLabel;


@end

@implementation CommentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setCommentModel:(CommentList *)commentModel
{
    _commentModel = commentModel;
    [_headPicImage sd_setImageWithURL:[NSURL URLWithString:commentModel.userPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    _usernameLabel.text = commentModel.userName;
    _timeLabel.text = [commentModel.createAt dealDate];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    [style setLineSpacing:3.0f];
    _contentLabel.attributedText = [[NSAttributedString alloc]initWithString:commentModel.commentTxt attributes:@{NSParagraphStyleAttributeName: style}];
    _praiseNumLabel.text = commentModel.praiseNum == nil ? @"0" : [NSString stringWithFormat:@"%@", commentModel.praiseNum];
    _commentNumLabel.text = commentModel.replyNum == nil ? @"0" : [NSString stringWithFormat:@"%@", commentModel.replyNum];
    height = 110 + [commentModel.commentTxt calculateWordsHeightWithFontSize:13 andWidth:SCREEN_WIDTH - 30] * 1.2;
}

+ (CGFloat)getHeight
{
    
    return height;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
